<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ include file="/interceptor.jsp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%@page isELIgnored="false" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>写邮件</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript">
	function addemail(){
		var recipients=document.getElementById("recipients").value;
		var title=document.getElementById("title").value;
		if(recipients == null||recipients=="" ){
			alert("收件人不能为空！");
		}else if(title == null||title=="" ){
			alert("邮件标题不能为空！");
		}else{
			document.forms[0].submit();
		}
	}
	
	 <%-- 验证附件是否大于9M --%>      
	function regist(){
  		var filename = document.getElementById("upload").value;
  		registor.isExist(filename, showResult);
  	}
  	function showResult(result){
  		if(result){
  			alert("附件附件上传成功");
  		}
  		else{
  			alert("附件不能大于9M");
  		}
	}
</script>
</head>

<body>
<form id="myForm" name="myForm" action="emailadd" method="post" enctype="multipart/form-data">
	<input type="hidden" name="email.sender" value="${user.nickName }"/>
	<input type="hidden" name="email.isRead" value="0"/>
	<input type="hidden" name="email.isDeleted" value="1"/>
        
	<div class="action">
		<div class="t">
			写邮件
		</div>
		<div class="pages">
			<table width="90%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td align="right" width="30%">收件人：</td>
                    <td align="left" colspan="2">
                    	<select id="recipients" name="email.recipients">
                        	<option value="">请选择</option>
                        <c:forEach var="recipients" items="${recipientsList}" varStatus="status">
                        	<option value="${recipients}">${recipients}</option>
                        </c:forEach>
                        </select>
                    </td>
				</tr>
				<tr>
					<td align="right" width="30%">邮件标题：</td>
                    <td align="left" colspan="2"><input type="text" name="email.title" id="title"/> <font color="#FF0000">*</font></td>
				</tr>
				<tr>
					<td align="right" width="30%">邮件内容：</td>
                    <td align="left" colspan="2"><textarea cols="40" rows="10" name="email.content" id="content"></textarea></td>
				</tr>
				<tr>
					<td align="right" width="30%">上传附件：</td>
                    <td align="left" colspan="2"> 
                    	<input type="file"  name="upload" id="upload"/>
                    	<font color="red">(上传附件不能大于 9 MB)</font>
                    </td><br/>
                    <font color="red">${alert }</font>
				</tr>
				<tr>
					<td align="center" colspan="2"><br/><input type="button" value="发送邮件" onclick="addemail()"/></td>
				</tr>
			</table>
			<div id ="message"><font color="red">${message }</font></div>			
		</div>
	</div>
</form>
</body>
</html>